package com.mk.admin.controller;

import com.mk.admin.log.WriteLog;
import com.mk.admin.model.ResultDto;
import com.mk.admin.model.vo.SysMenuVo;
import com.mk.admin.service.SysMenuService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/a/adm/sysMenu")
@Api(tags = "系统菜单")
public class SysMenuController {
    @Autowired
    private SysMenuService sysMenuService;

    @PostMapping("/select")
    public ResultDto select(@RequestBody SysMenuVo vo) {
        return sysMenuService.select(vo);
    }

    @PostMapping("/add")
    public ResultDto add(@RequestBody SysMenuVo vo) {
        return sysMenuService.add(vo);
    }

    @PostMapping("/update")
    public ResultDto update(@RequestBody SysMenuVo vo) {
        return sysMenuService.update(vo);
    }

    @PostMapping("/delete")
    public ResultDto delete(@RequestBody SysMenuVo vo) {
        return sysMenuService.delete(vo.getId());
    }

    @WriteLog("批量菜单删除")
    @PostMapping("/deleteBatchIds")
    public ResultDto deleteBatchIds(@RequestBody List<SysMenuVo> list) {
        return sysMenuService.deleteBatchIds(list);
    }

    @PostMapping("/status")
    public ResultDto status(@RequestBody SysMenuVo vo) {
        return sysMenuService.status(vo.getId());
    }
}
